/**
 * 本文主要演示几个:
 * 1.函数中参数的定义
 * 2.函数中参数的传递
 * 3.函数中参数的默认值
 * 4.函数的剩余参数
 * 5.函数的扩展运算符
 */

// 参数的传递

struct Daughter {
    name: String,
    age: u8,
    height: u8,
    score: u16,
}

fn fight(a: &mut Daughter, b: &mut Daughter) {
    println!("{} 打败了 {}", a.name, b.name);
    a.score += 1;
    b.score -= 1;
}

fn main() {
    let mut a = Daughter {
        name: "青莲".to_string(),
        age: 10,
        height: 120,
        score: 90,
    };
    let mut b = Daughter {
        name: "秋菊".to_string(),
        age: 10,
        height: 120,
        score: 90,
    };
    fight(&mut a, &mut b);
    //fight(&a, &b);  这样传递是不行的，虽然a,b是可变的，但不在传参的时候&a不等于&mut a.总之编译器就是这么规定的
    let a1 = &mut a;
    let b1 = &mut b;
    fight(a1, b1);
}
